package com.example.springbootjavacode.config;


import com.example.springbootjavacode.ConcreteBeanDefinitionRegistryPostProcessor;
import com.example.springbootjavacode.service.IService;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author: wukangrong
 * @date: 2020/12/31 10:50
 * @description:
 */
@Configuration
//@AutoConfigureAfter(value = {ConcreteBeanDefinitionRegistryPostProcessor.class})
public class ServiceConfig {



//    @ConditionalOnMissingBean(value = {IService.class})
//    @Bean
//    public IService getService() {
//        System.out.println("开始获取");
//        List<IService> iServices = SpringFactoriesLoader.loadFactories(IService.class, this.getClass().getClassLoader());
//        if (CollectionUtils.isEmpty(iServices)) {
//            throw new RuntimeException("service not found");
//        }
//        return iServices.get(0);
//    }

}
